//includes
//#include <vld.h>
#include "Game.h"

//prototype
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

//the windows main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	//create handle
	Handle m_handle(WindowProc,hInstance,nCmdShow);

	//declaration & init
	Game m_game;
	m_game.init(&m_handle);

	//main loop
	int m_error = EXIT_SUCCESS;
	while(m_game.running(m_error))
	{
		m_game.preLoop();
		m_game.input();
		m_game.update();
		m_game.draw();
		m_game.postLoop();
	}

	//release
	m_game.release();

	//exit
	return EXIT_SUCCESS;
}

//process messages
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
		break;
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}